package com.heny.demo.strategy.file;

import com.heny.demo.constants.Const;

import java.util.HashMap;
import java.util.Map;

/**
 * 文件策略类工厂
 * @author 邢益萌
 * {@code @date} 2025/9/12 14:55
 */
public class FileImportStrategyFactory {
    private static final Map<String, FileImportStrategy> STRATEGY_MAP = new HashMap<>();

    static {
        STRATEGY_MAP.put(Const.CSV, new CsvFileImportStrategy());
        STRATEGY_MAP.put(Const.TXT, new TxtFileImportStrategy());
        STRATEGY_MAP.put(Const.XLSX, new XlsxFileImportStrategy());
    }

    public static FileImportStrategy getStrategy(String fileType) {
        FileImportStrategy strategy = STRATEGY_MAP.get(fileType.toLowerCase());
        if (strategy == null) {
            throw new IllegalArgumentException("不支持的文件类型: " + fileType);
        }
        return strategy;
    }
}
